package algotithm.acwing.greedy.tes3485;

/**
 * @author 25068
 * @Date 2021/5/27 17:16
 * @Title 3485. 最大异或和
 */
import java.util.Scanner;

public class Main{
    private static final int N = 100010, M = 31 * N;

    private static int n, m;

    private static int[] s;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        m = scanner.nextInt();

        s = new int[N];
        for (int i = 1; i <= n; i ++) {
            int x = scanner.nextInt();
            s[i] = s[i - 1] ^ x;
        }

        Trie trie = new Trie(M);
        trie.insert(s[0] , 1);
        int res = 0;
        for (int i = 1; i <= n; i ++) {
            if (i > m ) {
                trie.insert(s[i - m - 1], -1);
            }
            res = Math.max(res, trie.query(s[i]));
            trie.insert(s[i], 1);
        }
        System.out.println(res);
    }

    private static class Trie {
        private final int BIT = 30;

        private int idx;
        private int[] cnt;
        private int[][] son;

        public Trie(int m) {
            cnt = new int[m];
            son = new int[m][2];
        }

        public void insert(int x, int flag) {
            int p = 0;
            for (int i = BIT; i >= 0 ;i -- ) {
                int u = x >> i & 1;
                if (son[p][u] == 0) {
                    son[p][u] = ++ idx;
                }
                p = son[p][u];
                cnt[p] += flag;
            }
        }

        public int query(int x) {
            int p = 0, res = 0;
            for (int i = BIT; i >= 0; i --) {
                int u = x >> i & 1;
                if (cnt[son[p][u ^ 1]] > 0) {
                    res = res * 2 + 1;
                    p = son[p][u ^ 1];
                } else {
                    res = res * 2;
                    p = son[p][u];
                }
            }
            return res;
        }
    }
}
